<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">ci_doc_draft</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">sys_user用户userName：</text></view>
                  <input  placeholder="请输入sys_user用户userName" v-model="model.userId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">文件编号（ES文档ID）：</text></view>
                  <input  placeholder="请输入文件编号（ES文档ID）" v-model="model.documentSn"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">文件题名：</text></view>
                  <input  placeholder="请输入文件题名" v-model="model.documentTitle"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">发文字号：</text></view>
                  <input  placeholder="请输入发文字号" v-model="model.documentIdentifier"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">公文类型编号：</text></view>
                  <input  placeholder="请输入公文类型编号" v-model="model.documentTypeSn"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">公文类型名称：</text></view>
                  <input  placeholder="请输入公文类型名称" v-model="model.documentTypeName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">业务类型编号：</text></view>
                  <input  placeholder="请输入业务类型编号" v-model="model.businessCategorySn"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">业务类型名称：</text></view>
                  <input  placeholder="请输入业务类型名称" v-model="model.businessCategoryName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">图标url：</text></view>
                  <input  placeholder="请输入图标url" v-model="model.businessCategoryUrl"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">文件正文：</text></view>
                  <input  placeholder="请输入文件正文" v-model="model.content"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">原文件路径：</text></view>
                  <input  placeholder="请输入原文件路径" v-model="model.realRoute"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">pdf文件保存路径：</text></view>
                  <input  placeholder="请输入pdf文件保存路径" v-model="model.pdfRoute"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">经办部门：</text></view>
                  <input  placeholder="请输入经办部门" v-model="model.departmentId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">经办部门名称：</text></view>
                  <input  placeholder="请输入经办部门名称" v-model="model.departmentName"/>
                </view>
              </view>
              <my-date label="发布日期：" v-model="model.publishedDate" placeholder="请输入发布日期"></my-date>
              <my-date label="废止日期：" v-model="model.abolitionDate" placeholder="请输入废止日期"></my-date>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">启用状态：</text></view>
                  <input  placeholder="请输入启用状态" v-model="model.enableFlag"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">ES索引名称：</text></view>
                  <input  placeholder="请输入ES索引名称" v-model="model.esIndexName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否是附件 0否 1 是：</text></view>
                  <input  placeholder="请输入是否是附件 0否 1 是" v-model="model.isAnnex"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">依附制度汇编文件的Sn：</text></view>
                  <input  placeholder="请输入依附制度汇编文件的Sn" v-model="model.parentDocSn"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">html内容：</text></view>
                  <input  placeholder="请输入html内容" v-model="model.htmlText"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">html样式：</text></view>
                  <input  placeholder="请输入html样式" v-model="model.htmlStyle"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">经办人：</text></view>
                  <input  placeholder="请输入经办人" v-model="model.operator"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">核稿人意见：</text></view>
                  <input  placeholder="请输入核稿人意见" v-model="model.reviewerComments"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">综合管理部负责人意见：</text></view>
                  <input  placeholder="请输入综合管理部负责人意见" v-model="model.headerOpinion"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "CiDocDraftForm",
        components:{ myDate },
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/compilation/ciDocDraft/queryById",
                  add: "/compilation/ciDocDraft/add",
                  edit: "/compilation/ciDocDraft/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
